package com.shopping.dao.impl;

import java.util.List;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import com.shopping.bean.Goods;
import com.shopping.dao.UserHobbyDao;
import com.shopping.util.DBUtil;

public class UserHobbyDaoImpl implements UserHobbyDao {

	JdbcTemplate jt = new JdbcTemplate(DBUtil.getDataSource());
	
	@Override
	public List<Goods> selectGoods(int goodsId) {
		String sql = "SELECT * FROM goods WHERE goodsId = ?";
		return jt.query(sql, new BeanPropertyRowMapper<Goods>(Goods.class),goodsId);
	}

	@Override
	public List<Integer> selectGoodsId(int userId) {
		String sql = "SELECT goodsId FROM userhobby WHERE userId = ?";
		return jt.queryForList(sql, Integer.class,userId);
	}

}
